package my.action.article;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.http.*;

import my.controller.*;
import my.db.DAO.ArticleDAO;
import my.db.DAO.ArticleTypeDAO;
import my.db.DTO.ArticleDTO;
import my.db.DTO.ArticleTypeDTO;
public class ArticleUpdateAction implements  Action{
	 public ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception{			
		 	ActionForward forward=new ActionForward();	
		 	ArticleDTO article=new ArticleDTO();
		 	ArticleDAO dao=new ArticleDAO();
		 	boolean help=true;
		 	int id=Integer.parseInt(request.getParameter("id"));
		 	article.setArticleNo(id);
		 	article.setArticleTitle(request.getParameter("articleTitle"));
		 	article.setArticleContent(request.getParameter("articleContent"));
		 	article.getArticleType().setTypeID(Integer.parseInt(request.getParameter("articleTypeID")));
		 	help=dao.editArticle(article);
			System.out.println("article ID"+id);
		 		if(help==true){
		 			forward.setPath("./list_article.article");
		 		}else{
		 			forward.setPath("./author_page.jsp?error=Unuccesseully Edit");
		 		}
		 
	  		return forward;
		}  	
}